#include "New.h"

void * new (const void * _type, ...)
{
	const struct TypeDescriptor *type =_type;
	void *p = malloc(type->size);
	assert(p);
	*(const struct TypeDescriptor **)p = type;
	if (type->ctor)
	{
		va_list a;
		va_start (a, _type);
		p = type->ctor(p, &a);
		va_end(a);
	}
	return p;
}

void delete ( void * uk)
{
	const struct TypeDescriptor **p = uk;
	if (uk && *p && (*p)->dtor )
	{
		uk = (*p)->dtor(uk);
	}
	free(uk);
}

